package com.yurui.proxy.cglib;

import org.springframework.cglib.proxy.Enhancer;
//
//import net.sf.cglib.proxy.Enhancer;

public class Client {

    public static void  main(String ... args) {
        System.out.println("***************");
        Client test = new Client();
        Target proxyTarget = (Target) test.createProxy(Target.class);
        String res = proxyTarget.execute();
        System.out.println(res);
    }

    public Object createProxy(Class targetClass) {
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(targetClass);
        enhancer.setCallback(new TargetMethodInterceptor());
        return enhancer.create();
    }
}
